package com.example.yunifang.adapter;

import java.util.ArrayList;

import com.example.yunifang.R;
import com.example.yunifang.bean.Fragment4Bean;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Fragment4Adapter extends BaseAdapter {
	Context context;
	ArrayList<Fragment4Bean> data;

	public Fragment4Adapter(Context context, ArrayList<Fragment4Bean> data) {
		super();
		this.context = context;
		this.data = data;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return data.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view=View.inflate(context, R.layout.fragment4_list_item, null);
		TextView name=(TextView) view.findViewById(R.id.fragment_list_item_name);
		ImageView img=(ImageView) view.findViewById(R.id.fragment_list_item_img);
		name.setText(data.get(position).getName());
		img.setImageResource(data.get(position).getImg());
		return view;
	}

}
